﻿<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title>学校排序</title>
	<link rel="stylesheet" href="css/common2.css">
</head>

<body class="main-body">
	<div id="vue-root" style="margin-top: 20px;">
		<div style="margin-left: 20px;">
			设备最新请求时间<input name="type" type="radio" value="0" v-model="type">
			打卡次数<input name="type" type="radio" value="1" v-model="type">
			最后登录时间 <input name="type" type="radio" value="2" v-model="type">
		</div>

		<div class="table">
			<table class="table_top">
				<thead>
					<tr>
						<th>
							<input type="checkbox" class="check-box" v-model="all">
						</th>
						<th>序号</th>
						<th>学校</th>
						<th>{{['设备最新请求时间','打卡次数','最后登录时间'][type]}}</th>
						<th>进入</th>
					</tr>
				</thead>
				<tbody id="list">
					<tr v-for="(a,index) in list" :key="a.id">
						<td>
							<input type="checkbox" class="check-box" v-model="a.checked">
						</td>
						<td><span v-text="index+1"></span></td>
						<td v-text="a.name"></td>
						<td>
							<template v-if="type==0">{{a.time.replace('T',' ')}}</template>
							<template v-else-if="type==1">{{a.count}}</template>
							<template v-else>{{createTime(a.rid)}}</template>
						</td>
						<td>
							<button @click="loginSchool(a.id)">进入学校</button>
						</td>
					</tr>
				</tbody>
			</table>
		</div>

		<a :href="urls.list+'/export'">
			<button>导出</button>
		</a>

		<ul class="pagination" v-if="pages>1">
			<li>
				<a v-if="pageNum!=1" @click="pageNum=1">«</a>
				<a class="pages-jump" v-if="pageNum!=1" @click="pageNum--">‹</a>
				<a v-text="pageNum"></a>
				<a class="pages-jump" v-if="pageNum!=pages" @click="pageNum++">›</a>
				<a v-if="pageNum!=pages" @click="pageNum=pages">»</a>
			</li>
		</ul>
	</div>

	<script src="/scriptZIP/vue.min.js"></script>
	<script src="/scriptZIP/axios.min.js"></script>
	<script src="/scriptZIP/dayjs.min.js"></script>

	<script src="/js/common.js"></script>
	<script src="/js/list.js"></script>

	<script>

		var app = new Vue(merge({
			data: {
				urls: {
					list: '/pc/home/sort/last'
				},
				type: 0
			},
			methods: {
				createTime: function (ts) {
					return dayjs(ts / 4096 + 1.56E12).format('YYYY-MM-DD HH:mm:ss');
				},
				loginSchool: function (id) {
					open("/school/school_menu.html?id=" + id, '_blank');
				},
			},
			watch: {
				type: function (nv, ov) {
					this.urls.list = '/pc/home/sort/' + ['last', 'count', 'last2'][nv];
					this.getData0();
				}
			}
		}));
	</script>

</body>

</html>